"""
@Time ： 2021/11/22 17:52
@Auth ： ChenZhangKun
"""
from socket import *


def receive():
    port = 8080
    # 创建套接字
    tcp_server = socket(AF_INET, SOCK_STREAM)
    tcp_server.bind(("", port))
    # 监听
    tcp_server.listen(128)
    # 接收消息
    new_client_socket, client_addr = tcp_server.accept()
    print(client_addr)
    # 接收客户端发过来的数据
    recv_data = new_client_socket.recv(1024)
    print(recv_data)
    # 发送数据
    new_client_socket.send("收到了".encode("utf-8"))
    new_client_socket.close()
    tcp_server.close()


if __name__ == '__main__':
    receive()